package org.yx.service.smat.view_material_sn_to_hold;

import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.utils.BaseService;

import com.xiaoleilu.hutool.util.StrUtil;

/**
 * 查询可锁定或已锁定的物料批次
 * @author zxw
 * @since 2018/05/20
**/
public class SmatViewMaterialSnToHoldService extends BaseService {
	public SmatViewMaterialSnToHoldOut viewMaterialSnToHold(SmatViewMaterialSnToHoldIn in) throws Exception {
		Query query = new Query(in.getPageIndex(), in.getPageSize());
		query.addFilter("orgCode", in.getUserOrgCode());
		if (!StrUtil.isBlank(in.getMatCode())) {
			query.addFilter("matCode", in.getMatCode());
		}
		if (!StrUtil.isBlank(in.getMatVer())) {
			query.addFilter("matVer", in.getMatVer());
		}
		if (!StrUtil.isBlank(in.getMsn())) {
			query.addFilter("msn", in.getMsn());
		}
		if (!StrUtil.isBlank(in.getHoldNo())) {
			query.addFilter("holdNo", in.getHoldNo());
		}

		Page<HoldMaterialSn> snPage = selectPageBySqlFilePath("select_material_sn_to_hold.sql", query, HoldMaterialSn.class);

		SmatViewMaterialSnToHoldOut out = new SmatViewMaterialSnToHoldOut();
		out.setMsnList(snPage.getList());
		out.setTotalSize(snPage.getTotalSize());

		return out;
	}
}